/*     */ package com.zhonglee.util;
/*     */ 
/*     */ import com.zhonglee.register.RegisterPropertiesUtils;
/*     */ import com.zhonglee.register.SerialCodeUtils;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class SerialCodeSample
/*     */ {
/*     */   private static Map map;
/*  20 */   private static boolean bInited = false;
/*  21 */   private static boolean bRegSuccessed = false;
/*  22 */   private static boolean bEverRCode = false;
/*  23 */   private static Date everDate = new Date("31-DEC-2999 23:59");
/*     */ 
/*     */   private static Map initCode() {
/*  26 */     String machineCode = SerialCodeUtils.getMachineCode();
/*  27 */     String _serialCode = RegisterPropertiesUtils.getInstance(getContextRealPath()).getSerialCode();
/*     */ 
/*  29 */     Date usefulLife = null;
/*  30 */     map = new HashMap();
/*     */ 
/*  32 */     if (_serialCode == null) {
/*  33 */       map.put("tip", "请输入序列号。");
/*  34 */       _serialCode = "";
/*  35 */     } else if (SerialCodeUtils.validateSerialCode(_serialCode)) {
/*  36 */       usefulLife = SerialCodeUtils.getUsefulLife(_serialCode);
/*  37 */       if (usefulLife.getTime() > everDate.getTime()) {
/*  38 */         map.put("tip", "序列号有效。");
/*  39 */         bEverRCode = true;
/*  40 */         bRegSuccessed = true;
/*  41 */       } else if (usefulLife.getTime() < new Date().getTime()) {
/*  42 */         map.put("tip", "序列号过期。");
/*     */       } else {
/*  44 */         map.put("tip", "试用序列号。");
/*  45 */         bRegSuccessed = true;
/*     */       }
/*     */     } else {
/*  48 */       map.put("tip", "序列号有误。");
/*     */     }
/*     */ 
/*  51 */     if (usefulLife != null)
/*  52 */       map.put("usefulLife", TimeUtils.getShortTime(usefulLife));
/*     */     else {
/*  54 */       map.put("usefulLife", "");
/*     */     }
/*  56 */     map.put("machineCode", machineCode);
/*  57 */     map.put("serialCode", SerialCodeUtils.getSerialCode(_serialCode));
/*     */ 
/*  59 */     bInited = true;
/*  60 */     return map;
/*     */   }
/*     */ 
/*     */   public static Map matchCode(String serialCode) {
/*  64 */     Map MapTmp = new HashMap();
/*     */ 
/*  66 */     String machineCode = SerialCodeUtils.getMachineCode();
/*  67 */     MapTmp.put("machineCode", machineCode);
/*  68 */     MapTmp.put("usefulLife", "");
/*  69 */     MapTmp.put("serialCode", serialCode);
/*  70 */     if (!SerialCodeUtils.validateSerialCode(serialCode)) {
/*  71 */       MapTmp.put("tip", "序列号有误。");
/*  72 */       bRegSuccessed = false;
/*  73 */     } else if (SerialCodeUtils.getUsefulLife(serialCode).getTime() > everDate.getTime()) {
/*  74 */       MapTmp.put("usefulLife", TimeUtils.getShortTime(SerialCodeUtils.getUsefulLife(serialCode)));
/*  75 */       MapTmp.put("tip", "合法序列号。");
/*  76 */       System.out.println("永恒有效序列号！");
/*  77 */       bRegSuccessed = true;
/*  78 */       bEverRCode = true;
/*  79 */       map.clear();
/*  80 */       map = MapTmp;
/*  81 */       RegisterPropertiesUtils.getInstance(getContextRealPath()).setSerialCode(serialCode);
/*  82 */     } else if (SerialCodeUtils.getUsefulLife(serialCode).getTime() < new Date().getTime()) {
/*  83 */       MapTmp.put("usefulLife", TimeUtils.getShortTime(SerialCodeUtils.getUsefulLife(serialCode)));
/*  84 */       MapTmp.put("tip", "序列号已过期。");
/*  85 */       bRegSuccessed = false;
/*     */     } else {
/*  87 */       MapTmp.put("usefulLife", TimeUtils.getShortTime(SerialCodeUtils.getUsefulLife(serialCode)));
/*  88 */       System.out.println("有效期年份：" + SerialCodeUtils.getUsefulLife(serialCode).getYear());
/*  89 */       MapTmp.put("tip", "试用序列号。");
/*  90 */       bRegSuccessed = true;
/*  91 */       if (!bEverRCode) {
/*  92 */         map.clear();
/*  93 */         map = MapTmp;
/*  94 */         RegisterPropertiesUtils.getInstance(getContextRealPath()).setSerialCode(serialCode);
/*     */       }
/*     */     }
/*  97 */     return MapTmp;
/*     */   }
/*     */ 
/*     */   public static Map getMap() {
/* 101 */     if (bInited) {
/* 102 */       return map;
/*     */     }
/* 104 */     return initCode();
/*     */   }
/*     */ 
/*     */   public static synchronized boolean getRegStatus() {
/* 108 */     if (!bInited)
/* 109 */       initCode();
/* 110 */     return bRegSuccessed;
/*     */   }
/*     */ 
/*     */   private static String getContextRealPath() {
/* 114 */     return System.getProperty("user.dir");
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.zhonglee.util.SerialCodeSample
 * JD-Core Version:    0.6.2
 */